package com.sise.aio和bio和nio.aio.基于aio的聊天室.test2;

import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousServerSocketChannel;
import java.nio.channels.AsynchronousSocketChannel;
import java.util.concurrent.ExecutionException;

/**
 * @author idea
 * @data 2019/1/22
 */
public class AIOClient {

    public static void main(String[] args) throws InterruptedException, IOException, ExecutionException {
        System.out.println("客户端启动了");
        AsynchronousSocketChannel channel = AsynchronousSocketChannel.open();
        channel.connect(new InetSocketAddress(InetAddress.getLocalHost(),9009)).get();

        ByteBuffer buffer=ByteBuffer.wrap("asdasdasd".getBytes());
        channel.write(buffer);
        System.out.println("发送结束");
        Thread.sleep(10000);
    }

}
